<div>

  <div class="margin-content signup-disabled" *ngIf="signupDisabled">
    <div class="alert alert-warning" i18n>Signup is not enabled on this instance.</div>
  </div>

  <ng-container *ngIf="!signupDisabled">
    <h1 class="title-page-v2">
      <strong class="underline-orange">{{ instanceName }}</strong>
      >
      <my-signup-label [requiresApproval]="requiresApproval"></my-signup-label>
    </h1>

    <div class="register-content">
      <my-custom-stepper linear>

        <cdk-step i18n-label label="About" [editable]="!signupSuccess">
          <my-signup-step-title mascotImageName="about">
            <strong>
              <my-signup-label [requiresApproval]="requiresApproval"></my-signup-label>
            </strong>

            <div i18n>on {{ instanceName }}</div>
          </my-signup-step-title>

          <my-register-step-about [requiresApproval]="requiresApproval" [videoUploadDisabled]="videoUploadDisabled"></my-register-step-about>

          <div class="step-buttons">
            <a i18n class="skip-step underline-orange" routerLink="/login">
              <strong>I already have an account</strong>, I log in
            </a>

            <button cdkStepperNext>
              <my-signup-label [requiresApproval]="requiresApproval"></my-signup-label>
            </button>
          </div>
        </cdk-step>

        <cdk-step [stepControl]="formStepTerms" i18n-label label="Terms" [editable]="!signupSuccess">
          <my-signup-step-title mascotImageName="terms" i18n>
            <strong>Terms</strong>
            <div>of {{ instanceName }}</div>
          </my-signup-step-title>

          <my-instance-about-accordion
            #instanceAboutAccordion
            [displayInstanceName]="false"
            (init)="onInstanceAboutAccordionInit($event)" [panels]="instanceInformationPanels"
            pluginScope="signup" pluginHook="filter:signup.instance-about-plugin-panels.create.result"
          ></my-instance-about-accordion>

          <my-register-step-terms
            [hasCodeOfConduct]="!!aboutHtml.codeOfConduct" [minimumAge]="minimumAge" [instanceName]="instanceName"
            [requiresApproval]="requiresApproval"
            (formBuilt)="onTermsFormBuilt($event)" (termsClick)="onTermsClick()" (codeOfConductClick)="onCodeOfConductClick()"
          ></my-register-step-terms>

          <div class="step-buttons">
            <button cdkStepperPrevious>{{ defaultPreviousStepButtonLabel }}</button>
            <button cdkStepperNext [disabled]="!formStepTerms || !formStepTerms.valid">{{ defaultNextStepButtonLabel }}</button>
          </div>
        </cdk-step>

        <cdk-step [stepControl]="formStepUser" i18n-label label="My account" [editable]="!signupSuccess">
          <my-signup-step-title mascotImageName="account" i18n>
            <strong>Setup</strong>
            <div>your account</div>
          </my-signup-step-title>

          <my-register-step-user
            (formBuilt)="onUserFormBuilt($event)"
            [videoUploadDisabled]="videoUploadDisabled" [requiresEmailVerification]="requiresEmailVerification"
          ></my-register-step-user>

          <div class="step-buttons">
            <button cdkStepperPrevious>{{ defaultPreviousStepButtonLabel }}</button>
            <button cdkStepperNext [disabled]="!formStepUser || !formStepUser.valid" (click)="videoUploadDisabled && signup()">{{ stepUserButtonLabel }}</button>
          </div>
        </cdk-step>

        <cdk-step *ngIf="!videoUploadDisabled" [optional]="true" [stepControl]="formStepChannel" i18n-label label="My channel" [editable]="!signupSuccess">
          <my-signup-step-title mascotImageName="channel" i18n>
            <div>Create</div>
            <strong>your first channel</strong>
          </my-signup-step-title>

          <my-register-step-channel
            (formBuilt)="onChannelFormBuilt($event)"
            [videoQuota]="videoQuota" [instanceName]="instanceName" [username]="getUsername()"
          ></my-register-step-channel>

          <div class="step-buttons">
            <button cdkStepperPrevious>{{ defaultPreviousStepButtonLabel }}</button>

            <div class="skip-step">
              <button class="underline-orange button-unstyle" (click)="skipChannelCreation()">
                <strong i18n>I don't want to create a channel</strong>
              </button>

              <div class="skip-step-description" i18n>You will be able to create a channel later</div>
            </div>

            <button cdkStepperNext [disabled]="!formStepChannel || !formStepChannel.valid || hasSameChannelAndAccountNames()" (click)="signup()">
              <my-signup-label [requiresApproval]="requiresApproval"></my-signup-label>
            </button>
          </div>
        </cdk-step>

        <cdk-step #lastStep i18n-label label="Done!" [editable]="false">
          <!-- Account creation can be a little bit long so display a loader  -->
          <div *ngIf="!requiresApproval && !signupSuccess && !signupError" class="done-loader">
            <my-loader [loading]="true"></my-loader>

            <div i18n>PeerTube is creating your account...</div>
          </div>

          <div *ngIf="signupError" class="alert alert-danger">{{ signupError }}</div>

          <my-signup-success-before-email
            *ngIf="signupSuccess"
            [requiresEmailVerification]="requiresEmailVerification" [requiresApproval]="requiresApproval" [instanceName]="instanceName"
          ></my-signup-success-before-email>

          <div *ngIf="signupError" class="step-buttons">
            <button cdkStepperPrevious>{{ defaultPreviousStepButtonLabel }}</button>
          </div>
        </cdk-step>
      </my-custom-stepper>
    </div>
  </ng-container>

</div>
